package io.gitee.chearnee.fw.web.page;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.Setter;

/**
 * @author cn
 * @version 1.0
 * @date 2021/5/24 18:55
 */
@Setter
public class QueryPage {

  /**
   * 当前页码
   */
  private Long current = 1L;
  /**
   * 每页数量
   */
  private Long pageSize = 10L;

  public Long getCurrent() {
    if (null == current || current <= 0) {
      current = 1L;
    }
    return current;
  }

  public Long getPageSize() {
    if (null == pageSize || pageSize <= 0) {
      pageSize = 10L;
    }
    return pageSize;
  }

  public <T> IPage<T> toPage() {
    return new Page<>(getCurrent(), getPageSize());
  }
}
